#include <iostream>
#include <stack>
using namespace std;

const int N = 110;

bool stk[N];

int main()
{
	string s; cin >> s;
	stack<int> st;
	for (int i = 0; i < s.size(); i++)
	{
		char ch = s[i];
		if (ch == '(' || ch == '[') st.push(i);
		else 
		{
			if (st.empty()) continue;
			char left = s[st.top()];
			if (ch == ']' && left == '[')
			{
				stk[i] = stk[st.top()] = true;
				st.pop();
			}
			else if (ch == ')' && left == '(')
			{
				stk[i] = stk[st.top()] = true;
				st.pop();
			}
		}
	}
	string ret = "";
	for (int i = 0; i < s.size(); i++)
	{
		char ch = s[i];
		if (stk[i]) ret += ch;
		else 
		{
			if (ch == '[')
			{
				ret += ch;
				ret += ']';
			}
			else if (ch == ']')
			{
				ret += '[';
				ret += ch;
			}
			else if (ch == '(')
			{
				ret += ch;
				ret += ')';
			}
			else 
			{
				ret += '(';
				ret += ch;
			}
		}
	}
	cout << ret << endl;
	
	return 0;
}
